package gov.tax.rti.com.zhyw.zcgl.controller;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;

/**
 * test
 * @author Administrator
 * 2013年12月20日上午9:10:01
 * email:simon.liang@bstek.com
 */
@Component
public class TestController {

	/**
	 * 查询
	 * @author Administrator
	 * 2013年12月20日上午9:09:25
	 * email:simon.liang@bstek.com
	 * @return
	 */
	@DataProvider
	public Map<String, Object> getTest2() {
		Map<String, Object> grade = new HashMap<String, Object>();
		grade.put("grade", "一年级");
		List<Map<String, Object>> listClass = new ArrayList<Map<String, Object>>();
		int j = 1;
		for (int i = 1; i < 11; i++) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("class_", i + "班");
			List<Map<String, Object>> listStudent = new ArrayList<Map<String, Object>>();
			for (; j < i * 10; j++) {
				Map<String, Object> student = new HashMap<String, Object>();
				student.put("student", j + "学生");
				listStudent.add(student);
			}
			map.put("list", listStudent);
			listClass.add(map);
		}
		grade.put("list", listClass);
		return grade;
	}

	/**
	 * 提交
	 * @author Administrator
	 * 2013年12月20日上午9:09:29
	 * email:simon.liang@bstek.com
	 * @param map
	 */
	@DataResolver
	public void updateTest2(Map<String, Object> map) {
		String grade = (String) map.get("grade");
		System.out.println(grade);
		@SuppressWarnings("unchecked")
		Collection<Map<String, Object>> classList = (Collection<Map<String, Object>>) map.get("list");
		for (Map<String, Object> class_ : classList) {
			String className = (String) class_.get("class_");
			System.out.println(className);
			@SuppressWarnings("unchecked")
			Collection<Map<String, Object>> studentList = (Collection<Map<String, Object>>) class_.get("list");
			for (Map<String, Object> student : studentList) {
				System.out.println(student.get("student"));
			}
		}
	}
}
